function getList(){
	$.ajax({
		"url":"/inventory/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"async":false,
		"complete":stop_load_pic,
		"dataType":"jsonp",
		"success":function(data){
			if(!data.status){
				showErrorInfo(data.content)
				return false;
			}
			var tab=document.getElementById("tab")
			data=data.content;
			for(var i=0;i<data.length;i++){
				var tr=document.createElement("tr")
				var td=document.createElement("td")
				var span=document.createElement("span")
				span.style.cursor="pointer"
				span.setAttribute("sid",data[i].id)
				span.setAttribute("value",data[i].value)
				span.onclick=function(){
					if($(this).hasClass("glyphicon-unchecked")){
						$(this).removeClass("glyphicon-unchecked").addClass("glyphicon-check")
					}
					else{
						$(this).removeClass("glyphicon-check").addClass("glyphicon-unchecked")
					}
				}
				span.className="glyphicon glyphicon-unchecked"
				td.appendChild(span)
				tr.appendChild(td)
			

				var td=document.createElement("td")
				td.textContent=data[i].content;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].type;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].value;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].name;
				tr.appendChild(td)
			
			
				
				tab.appendChild(tr)
			
			}
		}
	})
	var s=getQ().inventory_id
	s=JSON.parse(s)
	for(var i=0;i<s.length;i++){
		$("#tab").find("span[sid='" + s[i] + "']").removeClass("glyphicon-unchecked").addClass("glyphicon-check")
	}
	
}
document.getElementById("selectAll").onclick=function(){
		if($(this).hasClass("glyphicon-unchecked")){
			$("#tab span").removeClass("glyphicon-unchecked").addClass("glyphicon-check")
			$(this).removeClass("glyphicon-unchecked").addClass("glyphicon-check")
		}
		else{
			$("#tab span").removeClass("glyphicon-check").addClass("glyphicon-unchecked")
			$(this).removeClass("glyphicon-check").addClass("glyphicon-unchecked")
		}
}
document.getElementById("confirm").onclick=function(){
	var s=[]
	var value=0
	$("#tab .glyphicon-check").each(function(){
		var id=this.getAttribute("sid")
		value+=parseInt(this.getAttribute("value"))
		s.push(id)
	})
	if(s.length===0){
		showErrorInfo("请选择习题！")
		return false;
	}
	_s=JSON.stringify(s)
	var t=window.opener.document.getElementById("inventory_id")
	window.opener.document.getElementById("value").value=value
	t.setAttribute("s",_s)
	t.value="已选中 "+s.length+" 道题"
	window.close()
}
getList()
